﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnimaGestionPersonnage.Utilities
{
    /// <summary>
    /// La classe definissant les armes.
    /// </summary>
    public class Weapon : IEquatable<Weapon>, IComparer<Weapon>, IComparable<Weapon>
    {
        public string name { get; set; }
        public int damage { get; set; }
        public int speed { get; set; }
        public List<int> reqStr { get; set; }
        public List<DamageTypes> modes { get; set; }
        public List<WeaponTypes> types { get; set; }
        public List<WeaponSpecials> special { get; set; }
        public string notes { get; set; }
        public int fortitude { get; set; }
        public int breakage { get; set; }
        public int presence { get; set; }

        public Weapon()
        {
            reqStr = new List<int>();
            modes = new List<DamageTypes>();
            types = new List<WeaponTypes>();
            special = new List<WeaponSpecials>();
        }

        public Weapon(string n)
            : this()
        {
            this.name = n;
        }

        public override string ToString()
        {
            return this.name;
        }

        public bool Equals(Weapon other)
        {
            return name.Equals(other.name);
        }

        public int Compare(Weapon x, Weapon y)
        {
            return x.name.CompareTo(y.name);
        }

        public int CompareTo(Weapon other)
        {
            return name.CompareTo(other.name);
        }

        internal WeaponRelations getRelation(Weapon weapon)
        {
            WeaponRelations tempRelation = WeaponRelations.Erreur;
            foreach (WeaponTypes wt in this.types)
            {
                foreach (WeaponTypes wt2 in weapon.types)
                {
                    if (wt != wt2 && tempRelation == WeaponRelations.Similaire)
                    {
                        tempRelation = WeaponRelations.Mixte;
                    }
                    else if (wt == wt2 && tempRelation == WeaponRelations.Distincte)
                    {
                        tempRelation = WeaponRelations.Mixte;
                    }
                    else if (wt == wt2)
                    {
                        tempRelation = WeaponRelations.Similaire;
                    }
                    else
                    {
                        tempRelation = WeaponRelations.Distincte;
                    }
                }
            }
            return tempRelation;
        }
    }
}
